﻿--#include "data\config\mail\MailEventConfig.lua" once 	--触发事件发邮件

--触发邮件事件
function OnMailEvent( sysarg, value1, value2 )
	--print("OnMailEvent, mailEventId="..mailEventId..", value1="..value1..", value2="..value2)
	local  day = System.getDaysSinceOpenServer()
	local sVar = Actor.getStaticVar(sysarg)
	if not sVar.mailEvent then
		sVar.mailEvent = {}
	end
	for idx = 1, #MailEventCfg do
		local eventcfg = MailEventCfg[idx]
		if eventcfg and eventcfg.cond and eventcfg.cond[1] <= day and day <= eventcfg.cond[2] 
			and eventcfg.isUse and eventcfg.isUse == 1 and eventcfg.mails then
			for ii = 1, #eventcfg.mails do
				local mailCfg = eventcfg.mails[ii]
				if mailCfg and mailCfg.cond and Actor.checkActorLevel(sysarg, mailCfg.cond[2], mailCfg.cond[1]) then
					local iii = mailCfg.cond[1] * 255 + mailCfg.cond[2]
					if not sVar.mailEvent[iii] or sVar.mailEvent[iii] == 0 then
						sVar.mailEvent[iii] = 1
						local logId = LogIds.MailLogId
						local logStr = Lang.LogTips.MailEvent
						Awards.GiveToMailById( Actor.getActorId(sysarg), mailCfg.awards, mailCfg.title, mailCfg.content, logId, logStr)
					end
				end 
			end
		end
	end
end

